package cn.iocoder.yudao.module.wms.dal.mysql.doc;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.wms.dal.dataobject.doc.DocDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wms.controller.admin.doc.vo.*;

/**
 * 仓储单据 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DocMapper extends BaseMapperX<DocDO> {

    default PageResult<DocDO> selectPage(DocPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DocDO>()
                .likeIfPresent(DocDO::getName, reqVO.getName())
                .eqIfPresent(DocDO::getCode, reqVO.getCode())
                .eqIfPresent(DocDO::getDocType, reqVO.getDocType())
                .eqIfPresent(DocDO::getDocNoPrefix, reqVO.getDocNoPrefix())
                .eqIfPresent(DocDO::getDocNoType, reqVO.getDocNoType())
                .eqIfPresent(DocDO::getDocNoLength, reqVO.getDocNoLength())
                .eqIfPresent(DocDO::getTransactionType, reqVO.getTransactionType())
                .eqIfPresent(DocDO::getControlAcceptOevr, reqVO.getControlAcceptOevr())
                .eqIfPresent(DocDO::getControlAcceptShort, reqVO.getControlAcceptShort())
                .eqIfPresent(DocDO::getControlIssueOevr, reqVO.getControlIssueOevr())
                .eqIfPresent(DocDO::getControlIssueShort, reqVO.getControlIssueShort())
                .eqIfPresent(DocDO::getAutoApprove, reqVO.getAutoApprove())
                .eqIfPresent(DocDO::getPrintId, reqVO.getPrintId())
                .eqIfPresent(DocDO::getStatus, reqVO.getStatus())
                .eqIfPresent(DocDO::getSort, reqVO.getSort())
                .eqIfPresent(DocDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DocDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DocDO::getRevision, reqVO.getRevision())
                .orderByDesc(DocDO::getId));
    }

    default DocDO selectByCode(String code) {
        return selectOne(DocDO::getCode, code);
    }

    default List<DocDO> selectList(Collection<Long> ids) {
        return selectList(DocDO::getId, ids);
    }
}